Skip to content

Run Ansible from CI with a dedicated ci user - #27

Merged
shenanigansd merged 5 commits into
mainfrom
claude/ansible-ci-user-setup-pwgw60
Aug 30, 2026
Merged

Run Ansible from CI with a dedicated ci user#27
shenanigansd merged 5 commits into
mainfrom
claude/ansible-ci-user-setup-pwgw60

Conversation

@shenanigansd

Copy link
Copy Markdown
Member

Runs the Ansible playbook from GitHub Actions as a dedicated ci user, keeping CI auth and logging separate from human access.

Changes

  • New users role (first play in playbook.yaml):
    • Creates the ci automation user: locked password, repo-managed authorized key (files/ci_ed25519.pub, exclusive: true), and NOPASSWD: ALL sudo via a visudo-validated /etc/sudoers.d/ci.
    • Creates the letsbuilda service user (system user, nologin, docker group) — previously consumed by the minecraft role but never created anywhere.
  • ansible-deploy.yaml workflow: runs the playbook on pushes to main touching ansible/** (plus workflow_dispatch), gated by an ansible GitHub Environment. Connects as ci (ANSIBLE_REMOTE_USER), keeps strict host-key checking via the committed ansible/known_hosts, and queues (not cancels) overlapping runs via a concurrency group.
  • New ansible-lint job in lint.yaml: ansible-lint + ansible-playbook --syntax-check on PRs and main — the existing ansible/.ansible-lint config was never actually installed or run in CI before. No secrets on PR-triggered runs.
  • Cleanup: dropped vault_password_file from ansible.cfg (pointed at a nonexistent file and would abort non-interactive runs; vault is unused), added .gitignore for it. become_ask_pass = yes stays for humans; CI overrides via env.
  • Docs: local runs, CI deploys, and the bootstrap/key-rotation procedure in docs/ansible.md, linked from the README.

Remaining setup before the first CI deploy

  1. Create the ansible GitHub Environment, restrict its deployment branches to main, and add the SSH_PRIVATE_KEY secret (the counterpart to the committed ci_ed25519.pub).
  2. One local bootstrap run of the playbook to create the ci user on microwave (chicken-and-egg — documented in docs/ansible.md).

Verification

  • ansible-lint passes at the production profile; playbook syntax check passes; all pre-commit hooks pass (zizmor clean in offline mode on both new/modified workflows).
  • Committed key material sanity-checked: both the CI public key and the pinned host key decode as valid ed25519 blobs, are distinct, and sit in the files the role/workflow read.

🤖 Generated with Claude Code

https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW


Generated by Claude Code

claude and others added 4 commits August 30, 2026 03:53
Add a users role that creates the ci automation user (locked password,
repo-managed authorized key, NOPASSWD sudo via /etc/sudoers.d/ci) and the
letsbuilda service user the minecraft role depends on but nothing created.

Deploy via a new ansible-deploy workflow on pushes to main touching
ansible/**, gated by the ansible GitHub Environment, connecting as ci
with a pinned host key. PRs get an ansible-lint + syntax check job (the
existing .ansible-lint config was never actually run in CI).

Drop the vault_password_file setting pointing at a nonexistent file and
document local runs, CI deploys, and the bootstrap procedure in the README.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW
Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev>
Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev>
@shenanigansd
shenanigansd requested a review from a team as a code owner August 30, 2026 04:42
@shenanigansd
shenanigansd merged commit 9a65f59 into main Aug 30, 2026
6 checks passed
@shenanigansd
shenanigansd deleted the claude/ansible-ci-user-setup-pwgw60 branch August 30, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants